package com.example.entity;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;

import org.springframework.stereotype.Component;

import com.fasterxml.jackson.annotation.JsonIgnore;

@Entity
public class Teacher {
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	private Integer id;
	private String name;
	private Integer age;
	private String sex;
	private String email;
	private String address;
	@OneToMany(mappedBy="teacher",cascade=CascadeType.ALL)
	@JsonIgnore
	private Set<Grade> grade;
	
    public Set<Grade> getGrade() {
		return grade;
	}

	public void setGrade(Set<Grade> grade) {
		this.grade = grade;
	}

	@ManyToMany(cascade=CascadeType.ALL)
    @JoinTable(name="maj_tea",joinColumns=@JoinColumn(name="teacher_id",referencedColumnName="id"),
    inverseJoinColumns=@JoinColumn(name="maj_id",referencedColumnName="id"))
	@JsonIgnore
	private Set<Major> major = new HashSet<>();
    @ManyToMany(mappedBy="teacher",cascade=CascadeType.ALL)
    @JsonIgnore
	private Set<Course> course = new HashSet<>();

	public Teacher() {

	}

	public Teacher(String name, Integer age, String sex, String email, String address, Set<Major> mojar,
			Set<Course> course, Set<Major> major) {
		super();
		this.name = name;
		this.age = age;
		this.sex = sex;
		this.email = email;
		this.address = address;
		this.major = major;
		this.course = course;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Integer getAge() {
		return age;
	}

	public void setAge(Integer age) {
		this.age = age;
	}

	public String getSex() {
		return sex;
	}

	public void setSex(String sex) {
		this.sex = sex;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public Set<Major> getMojar() {
		return major;
	}

	public void setStudent(Set<Major> major) {
		this.major = major;
	}

	public Set<Course> getCourse() {
		return course;
	}

	public void setCourse(Set<Course> course) {
		this.course = course;
	}
}
